Skip to content

Fix reactive streams MongoClient.getTimeout always returning null#2009

Merged
stIncMale merged 2 commits into
mongodb:mainfrom
stIncMale:JAVA-6246
Jul 6, 2026
Merged

Fix reactive streams MongoClient.getTimeout always returning null#2009
stIncMale merged 2 commits into
mongodb:mainfrom
stIncMale:JAVA-6246

Conversation

@stIncMale

@stIncMale stIncMale commented Jul 3, 2026

Copy link
Copy Markdown
Member

AI was used only to review.

JAVA-6246

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the Reactive Streams driver’s MongoClient.getTimeout(TimeUnit) implementation so it reports the configured operation timeout (instead of always returning null), and aligns nullability annotations with the public API contract.

Changes:

  • Reactive Streams: MongoClientImpl.getTimeout now delegates to the underlying cluster implementation.
  • Reactive Streams + Sync: add @Nullable to getTimeout overrides to match the MongoCluster API contract.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
driver-sync/src/main/com/mongodb/client/internal/MongoClientImpl.java Adds @Nullable to getTimeout override to match MongoCluster#getTimeout contract.
driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/MongoClusterImpl.java Adds @Nullable to getTimeout override (note: conversion logic in this method needs correction per review comment).
driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/MongoClientImpl.java Fixes Reactive Streams MongoClient.getTimeout to delegate instead of always returning null; marks return as @Nullable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

@stIncMale stIncMale marked this pull request as ready for review July 4, 2026 00:10
@stIncMale stIncMale requested a review from a team as a code owner July 4, 2026 00:10
@stIncMale stIncMale requested review from rozza and vbabanin and removed request for vbabanin July 4, 2026 00:10
rozza
rozza previously approved these changes Jul 6, 2026

@rozza rozza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend adding notNull checks for timeUnit - but understand your motiviations for not adding it.

LGTM

@stIncMale

Copy link
Copy Markdown
Member Author

I'd recommend adding notNull checks for timeUnit

Done in 0acc7ec.

@stIncMale stIncMale requested a review from rozza July 6, 2026 14:17
@Override
@Nullable
public Long getTimeout(final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the notNull checks to MongoClusterImpl and not MongoClientImpl to be consistent with the rest of the code. However, the approach is wrong, and the checks should be in MongoClientImpl instead, because at run time an application directly calls methods of MongoClientImpl, not MongoClusterImpl.

@rozza rozza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@stIncMale stIncMale merged commit d84dabb into mongodb:main Jul 6, 2026
53 checks passed
@stIncMale stIncMale deleted the JAVA-6246 branch July 6, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants